using System;
using System.Web;

namespace Journal.NHibernate.NHibernateManager
{
    public class NHibernateSessionModule : IHttpModule
    {
        #region IHttpModule Members

        public void Init(HttpApplication context)
        {
            context.EndRequest += this.CloseAllNHibernateSessions;
        }

        public void Dispose()
        {
        }

        #endregion

        private void CloseAllNHibernateSessions(object sender, EventArgs e)
        {
            NHibernateSessionManager.Instance.CloseAllSessions();
        }
    }
}